package hn.cch.advanced.concurrent;

import java.util.UUID;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

public class FutureTaskDemo {

    public static void main(String[] args) throws Exception {
        FutureTask<String> futureTask = new FutureTask<>(() -> {
            System.out.println(Thread.currentThread().getName() + ":call");
            return UUID.randomUUID().toString();
        });
        new Thread(futureTask, "thread").start();
        System.out.println(Thread.currentThread().getName() + ":" + futureTask.get(10, TimeUnit.SECONDS));
    }

}
